import matplotlib.pyplot as plt

sizes = [215, 130, 245, 210]
labels = ["Frogs", "Hogs", "Dogs", "Logs"]
colors = ["yellowgreen", "gold", "lightskyblue", "lightcoral"]

# 绘制饼图
patches, texts, autotexts = plt.pie(
    sizes,
    labels=labels,
    colors=colors,
    autopct="%1.1f%%",
    startangle=90,
    labeldistance=1.05,
)

# 可以进一步自定义文本和扇区
for text in texts:
    text.set_color("black")  # 将文本颜色设置为黑色
    text.set_fontsize(12)  # 设置文本大小

for text in autotexts:
    text.set_color("white")  # 将自动生成的文本颜色设置为白色

for patch in patches:
    patch.set_edgecolor("black")  # 将扇区边缘颜色设置为黑色

plt.axis("equal")  # 保持饼图的圆形
# plt.legend(loc="upper right")  # 添加图例
plt.show()
